const fs = require('fs')
const qgy = require('./qgy-table.json')
//
const show = require('./show-table.json')

console.log("qgy一共有机器:",qgy.length)

console.log("自我统计一共有机器:",show.length)

//qgy里面是否存在某台机器
function isVPSInQGY(id, ip){
  for(let j = 0, length = qgy.length; j < length; j++ ){
    let item = qgy[j]
    if(id == item.id && ip == item.ip){
      return true
    }
  }
  return false
}
//在统计里面查找机器
function isVPSInMyself(qgy){
  for(let j = 0, length = show.length; j < length; j++ ){
    let showItem = show[j].id
    let arr = showItem.split('-')
    let id = arr[0]
    let ip = arr[1]
    if(id == qgy.id && ip == qgy.ip){
      return true
    }
  }
  return false
}

//统计有，但是qgy没有
let diff = []
for(let i = 0, len = show.length; i < len; i++){
  let showItem = show[i].id

  let arr = showItem.split("-")
  let id = arr[0]
  let ip = arr[1]

  if(!isVPSInQGY(id, ip)){
    diff.push({id:id, ip:ip})
  }
}
console.log("统计里面有,但是qgy没有: \n",diff)

//青果云有，统计里面没有
let diff1 = []
for(let i = 0, len = qgy.length; i < len; i++){
  let item = qgy[i]
  if(!isVPSInMyself(item)){
    diff1.push(item)
  }
}
console.log("青果云有，统计里面没有:\n")
console.log(diff1)